<template>
	<view class="wrapper">
		<view class="content">
			<view class="cont-top" style="background: url(../../static/images/bg-tu.png);">
				<view class="-top-left">
					<view class="-top-img" @click="getloginType">
						<image  :src="UserInfo.avatar ? UserInfo.avatar :'../../static/images/user-icon.png'" mode="aspectFill"></image>
					</view>
					<view class="-top-text">
						<view class="-top-name">{{UserInfo.company ? UserInfo.company:'未登录'}}</view>
						<view class="-top-id">{{UserInfo.store_id?UserInfo.store_id:''}}</view>
						<view v-if="UserInfo.address" class="-top-address">
                            地址：{{UserInfo.address}}
						</view>
					</view>
				</view>
				
				<navigator url="./personal">
					<view class="set-btn">
						<image src="../../static/images/modify-icon.png"></image>
					</view>
				</navigator>
			</view>
			
			<view class="cont-nav">
				<view class="-nav-item" v-for="(item, index) in listData" :key="index" @click="toOthersMenu(item.url)">
					<view class="-nav-left">
						<image :src="item.img" mode="aspectFill"></image>
						<view class="-nav-text">{{item.name}}</view>
					</view>
					
					<view class="-nav-icon">
						<image src="../../static/images/right-icon.png"></image>
					</view>
				</view>
				
			</view>
			
		</view>
		
	</view>
</template>

<script>
	export default {
		data() {
			return {
				UserInfo:null,
				listData: [
					// {url:"../user/coupon",name:"优惠券管理",img:'../../static/images/yhqgl.png'},
					{url:"../user/customerAdmin",name:"客户管理",img:'../../static/images/khgl.png'},
					{url:"../user/salesman",name:"客户设置",img:'../../static/images/khsz.png'},
					{url:"../user/against",name:"意见反馈",img:'../../static/images/yjfk.png'},
					// {url:"../user/alerts",name:"消息通知",img:'../../static/images/xx.png'},
					// {url:"../user/groupOrder",name:"拼团订单"}
				]
				
			}
		},
		
		onShow() {
			if(uni.getStorageSync('storeMsg')){
				this.UserInfo =  JSON.parse(uni.getStorageSync('storeMsg'))
				// this.getuser_info();
			}else{
				uni.reLaunch({
					url:'./logIn'
				})
			}
		},
		methods: {
			getloginType(){
				if(uni.getStorageSync('store_id') == ''){
					uni.redirectTo({
						url:'./logIn'
					})
				}
			},
			//获取个人资料
			getuser_info:function(){
				var that = this;
				var store_id = uni.getStorageSync('store_id');
				uni.request({
					url: that.$websiteUrl + '/index.php/Api/User/get_user_detail.html', 
					data: {store_id:store_id},
					method:'POST',
					dataType:'json',
					header: {'content-type' : 'application/x-www-form-urlencoded'},
					success: (resa) => {
						var one = resa.data;
						if(one.status == 1){
							that.UserInfo = one.data;
							uni.setStorageSync('UserInfo',one.data)
						}else{
							that.$api.errorMsg(one.message);
							that.scode = false;
						}
						
					},
					fail:(resa)=> {
						that.$api.errorMsg('网络连接超时，请检查您的网络');
					}
				})
			},
			link(url){
				var that =this;
				uni.navigateTo({
					url:url
				})
			},
			toOthersMenu(url){
				var that =this;
				uni.navigateTo({
					url:url
				})
			},
			
		}
	}
</script>

<style lang="scss">
	@import url('../../common/common.css');
	
	// .wrapper {
	// 	position: absolute;
	// 	top: 0;
	// 	left: 0;
	// 	display: flex;
	// 	flex-direction: column;
	// 	width: 100%;
	// 	height: 100%;
	// }
	
	.content {
		padding-bottom: 100upx;
	}
	
	.cont-top {
		padding: 70upx 30upx 65upx;
		display: flex;
		align-items: center;
		justify-content: space-between;
		// background-size: 100% 100%;
		background-size: 100% 100% !important;
		.-top-left {
			display: flex;
			align-items: center;
			.-top-img {
				margin-right: 30upx;
				width: 120upx;
				height: 120upx;
				box-shadow: 0px 9upx 14upx 0px #ff0000;
				border-radius: 50%;
				image {
					border-radius: 50%;
				}
			}
			.-top-text {
				width: 400upx;
				.-top-name {
					font-size: 36upx;
					line-height: 55upx;
					color: #ffffff;
				}
				.-top-id {
					font-size: 28upx;
					line-height: 45upx;
					color: #ffffff;
				}
				.-top-address{
					font-size:28upx;
					font-family:Adobe Heiti Std;
					font-weight:normal;
					color:rgba(255,255,255,1);
				}
			}
		}
		.set-btn {
			width: 30upx;
			height: 30upx;
		}
	}
	
	.cont-nav {
		margin-top: -20upx;
		padding: 20upx 30upx;
		background: #fff;
		border-radius: 20upx 20upx 0 0;
		.-nav-item {
			display: flex;
			align-items: center;
			justify-content: space-between;
			line-height: 100upx;
			border-bottom: 1upx solid #eee;
			
			.-nav-left {
				display: flex;
				align-items: center;
				justify-content: flex-start;
				>image{
					width: 40upx;
					height: 40upx;
					margin-right: 20upx;
				}
				.-nav-text {
					font-size: 32upx;
					color: #333;
				}
			}
			.-nav-icon {
				width: 13upx;
				height: 21upx;
			}
		}
	}
	
	.order-top {
	    padding: 0 30upx;
	    display: flex;
	    align-items: center;
	    justify-content: space-between;
	    line-height: 100upx;
	}
	.order-t {
	    font-size: 30upx;
		font-weight: bold;
		color: #333;
	}
	.order-all {
		display: flex;
		align-items: center;
	    font-size: 24upx;
		color: #999;
	}
	.-all-icon {
		margin-left: 10upx;
		width: 13upx;
		height: 21upx;
	}
	.order-bot {
	    padding: 25upx 20upx 30upx;
	    display: flex;
	    justify-content: space-between;
	}
	.order-item {
	    flex: 1;
	}
	.order-icon {
	    margin: 0 auto;
	    width: 60upx;
	    height: 54upx;
	}
	.order-text {
	    font-size: 24upx;
	    text-align: center;
		line-height: 45upx;
		letter-spacing: 1px;
		color: #333;
	}
	
</style>
